home *** CD-ROM | disk | FTP | other *** search
- attacking = false;
- speed = 0;
- walking = false;
- if(!init)
- {
- orig_scale = _xscale;
- hitarea._visible = 0;
- walking = false;
- parrying = false;
- attacking = false;
- jumping = false;
- fall_distance = 0;
- init = true;
- side = "L";
- lastdecision = 0;
- deadcount = 0;
- floor = 62;
- walk_distance = 10;
- reach = 35;
- damage = 24;
- total_ki = 10;
- ki = total_ki;
- ki_cost = 5;
- pushfactor = 9;
- total_hp = 10 + _root.level * 5;
- hp = total_hp;
- regen_rate = 0.1;
- score = 1250;
- _root.createPic("pic_commando",this);
- }
- this.onEnterFrame = function()
- {
- if(!init)
- {
- return undefined;
- }
- if(dead)
- {
- deadcount++;
- if(deadcount > 1000)
- {
- trace("unloading:" + this);
- this.removeMovieClip();
- unloadMovie(this);
- }
- gotoAndStop("die");
- this._x -= _hitomi.speed;
- return undefined;
- }
- lastdecision++;
- onDie();
- doCalcs();
- var _loc3_ = fallback();
- if(_loc3_ == undefined)
- {
- _loc3_ = 0;
- }
- var _loc4_ = _root.hitomi.speed;
- checkHits();
- decide();
- this._x -= _loc4_;
- this._x += _loc3_;
- };
- checkHits = function()
- {
- if(this.hitarea.hitTest(_hitomi.hitarea))
- {
- onHit();
- }
- if(_root.hitomi.hitTest(_X + club._x * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- if(_root.hitomi.hitTest(_X + (club._x + 3) * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- if(_root.hitomi.hitTest(_X + (club._x - 3) * getDirection(),_Y + club._y,true))
- {
- _root.hitomi.recieveHit(this);
- }
- };
- doCalcs = function()
- {
- if(!(walking || attacking || jumping || parrying || turning || recieving))
- {
- ki += regen_rate;
- }
- if(ki > total_ki)
- {
- ki = total_ki;
- }
- if(hp > total_hp)
- {
- hp = total_hp;
- }
- if(ki < 0)
- {
- ki = 0;
- }
- if(hp < 1)
- {
- hp = 0;
- die();
- }
- pic.bars.hp._xscale = Math.ceil(hp / total_hp * 100);
- pic.bars.ki._xscale = Math.ceil(ki / total_ki * 100);
- };
- getDirection = function()
- {
- if(orig_scale == _xscale)
- {
- return 1;
- }
- return -1;
- };
- bombHit = function(hit_by, dmg, pushf)
- {
- hp -= dmg;
- };
- onHit = function()
- {
- _root.hitcount = _root.hitcount + 1;
- if(_root.hitcount > 1000)
- {
- _root.hitcount = 0;
- }
- hp -= _hitomi.damage;
- _root._score += _hitomi.damage;
- var _loc3_ = _root.attachMovie("mc_blood01","blood" + hitcount,6000 + hitcount);
- _loc3_._rotation = random(360);
- var _loc4_ = random(150) + 100;
- _loc3_._xscale = _loc4_;
- _loc3_._yscale = _loc4_;
- if(_hitomi.side == "R")
- {
- _loc3_._x = _hitomi._x + _hitomi.hitarea._x;
- _loc3_._y = _hitomi._y + _hitomi.hitarea._y;
- }
- else
- {
- _loc3_._x = _hitomi._x - _hitomi.hitarea._x;
- _loc3_._y = _hitomi._y + _hitomi.hitarea._y;
- }
- fall_distance = _hitomi.pushback * 2;
- fallback = function()
- {
- fall_distance--;
- if(fall_distance < 1)
- {
- delete this.fallback;
- fall_distance = 0;
- return 0;
- }
- return _hitomi.getDirection() * (fall_distance / 2);
- };
- soundsList = ["loud_metal_hit","blow01","beat","cabasa","zddd1kick1","zddd1kick2","zddd1tamb"];
- playSound(soundsList);
- };
- die = function()
- {
- _root.removePic(pic);
- dead = true;
- walking = false;
- slashing = false;
- attacking = false;
- speed = 0;
- gotoAndStop("die");
- play();
- };
- decide = function()
- {
- if(dead)
- {
- return undefined;
- }
- if(!attacking || lastdecision > 75)
- {
- lastdecision = 0;
- if(random(120) == 0)
- {
- if(random(2) == 0)
- {
- _X = _hitomi._x + reach + random(6);
- _xscale = orig_scale;
- }
- else
- {
- _X = _hitomi._x - reach - random(6);
- _xscale = - orig_scale;
- }
- attack();
- }
- }
- };
- attack = function()
- {
- if(!attacking)
- {
- walking = false;
- speed = 0;
- attacking = true;
- ki -= ki_cost;
- gotoAndStop("hit");
- play();
- }
- };
- if(!init)
- {
- side = "L";
- orig_scale = _xscale;
- init = true;
- }
- slash1 = function()
- {
- if(jumping || slashing)
- {
- return undefined;
- }
- slashing = true;
- gotoAndStop("hit");
- play();
- };
- right = function()
- {
- turn("R");
- };
- left = function()
- {
- turn("L");
- };
- turn = function(sideto)
- {
- if(!sideto)
- {
- if(side == "L")
- {
- sideto = "R";
- }
- else
- {
- sideto = "L";
- }
- }
- if(side != sideto)
- {
- if(!jumping)
- {
- turnTo = sideto;
- walking = false;
- jumping = false;
- parrying = false;
- if(sideto == "L")
- {
- _xscale = orig_scale;
- }
- else
- {
- _xscale = - orig_scale;
- }
- side = sideto;
- }
- }
- else
- {
- turning = false;
- }
- };
- playSound = function(ids)
- {
- _root.sounds.playSound(ids);
- };
- stop();
-